#include "widget.h"
#include "ui_widget.h"
#include <QMovie>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    //栈控件使用

    //设置scroll area为初始页
    ui->stackedWidget->setCurrentIndex(0);

    //点击第一页出现scroll area页面
    connect(ui->btn_one,&QPushButton::clicked,[=]()
    {
        ui->stackedWidget->setCurrentIndex(0);
    });

    //点击第二页出现toolbox页面
    connect(ui->btn_two,&QPushButton::clicked,[=]()
    {
        ui->stackedWidget->setCurrentIndex(1);
    });

    //点击第三页出现tab widget页面
    connect(ui->btn_three,&QPushButton::clicked,[=]()
    {
        ui->stackedWidget->setCurrentIndex(2);
    });

    //下拉框的使用combobox
    ui->comboBox->addItem("car");
    ui->comboBox->addItem("bus");
    ui->comboBox->addItem("bicycle");

    //点击按钮选中bicycle
    connect(ui->btn_bicycle,&QPushButton::clicked,[=]()
    {
        //或者 ui->comboBox->setCurrentIndex(2);
        ui->comboBox->setCurrentText("bicycle");
    });

    //利用QLabel显示图片
    ui->label->setPixmap(QPixmap(":/image/1301448.gif"));
    //利用QLabel显示动图
    QMovie * qmovie = new QMovie(":/image/1307039.gif");
    ui->label_2->setMovie(qmovie);
    //播放动图
    qmovie->start();


}

Widget::~Widget()
{
    delete ui;
}
